# -*- coding: utf-8 -*-
from db.mysql import MysqlClient
from common.helper import Helper
from pprint import pprint


class Arrangement(object):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "贴心保综合意外伤害保险"

    def pullData(self, data={}):
        for item in Helper.selectData(self.name, self.mysql):
            data["name"] = self.name
            data["company"] = "阳光保险集团"
            data["days"] = item["days"]
            data["people_count"] = item["people_count"]
            data["professions"] = "'" + item["professions"] + "'"
            data["accident_death"] = item["accident_death"]
            data["accident_disable"] = item["accident_disable"] + "0000"
            data["accident_hospital"] = item["accident_hospital"]
            data["price"] = item["price"]
            Sql = 'INSERT INTO `accident`(`name`,`company`,`days`,`people_count`,`professions`,`accident_death`,`accident_disable`,`accident_hospital`,`price`)VALUES("{name}","{company}","{days}","{people_count}",{professions},"{accident_death}","{accident_disable}","{accident_hospital}","{price}")'
            print(Sql.format(**data))
            self.mysql.cursor.execute( Sql.format( **data ))
            self.mysql._conn.commit()
            print( Sql.format( **data )  )
